<?php

// error_reporting(0);
// define('IN_MOBILE', true);
// require dirname(__FILE__).'/../../../../framework/bootstrap.inc.php';
// require IA_ROOT.'/addons/ewei_shopv2/defines.php';
// require IA_ROOT.'/addons/ewei_shopv2/core/inc/functions.php';
// require IA_ROOT.'/addons/ewei_shopv2/core/inc/plugin_model.php';
// require IA_ROOT.'/addons/ewei_shopv2/core/inc/com_model.php';

require_once('AopClient.php');
require_once('AlipayTradeAppPayRequest.php');
require_once('AopEncrypt.php');

class Alipay_EweiShopV2Page extends MobilePage
{
	 public function pay_data()
	 {
	 	   $fee=$_POST['fee'];
	         	    $rand = rand(10000, 99999);
	                $order=$_POST['ordersn'];
	                $set_ali_appid=    $_POST['ali_appid'];
	                $set_ali_PrivateKey=   $_POST['ali_private_key_rsa2'];    
	                $set_ali_PublicKey= $_POST['ali_public_key_rsa2'];       

	                $ali_notify_url= $_POST['ali_notify_url'];
	                $pay_attach=$_POST['pay_attach'];
                    $pay_aliname=$_POST['pay_aliname'];

	         	    $result_ali_pay_data =$this->Alipay( $fee,$order,  $pay_aliname,$pay_attach,$set_ali_appid,$set_ali_PrivateKey,$set_ali_PublicKey,$ali_notify_url);//==================================用户自定义参数
					echo $result_ali_pay_data   ;
	 }
	    public function Alipay($price,$id,$pay_aliname,$pay_attach,$appId,$PrivateKey,$PublicKey,$ali_notify_url)
                 {
	    $aop = new AopClient;
	    $aop->gatewayUrl = "https://openapi.alipay.com/gateway.do";
	   
	    $aop->appId = $appId;
	    
	    $aop->rsaPrivateKey = $PrivateKey;
	  
	    $aop->alipayrsaPublicKey = $PublicKey;
	    $aop->format = "json";
	    $aop->charset = "UTF-8";
	    $aop->signType = "RSA2";
	    $request = new AlipayTradeAppPayRequest();
	    $bizcontent = "{\"body\":\"$pay_attach\","
	        . "\"subject\": \"$pay_aliname\","
	        . "\"out_trade_no\": \"$id\","
	        . "\"timeout_express\": \"30m\","
	        . "\"total_amount\": \"$price\","
	        . "\"product_code\":\"QUICK_MSECURITY_PAY\""
	        . "}";
	    $request->setNotifyUrl($ali_notify_url);
	    $request->setBizContent($bizcontent);
	    $response = $aop->sdkExecute($request);
	    return $response;
	    
	}   

}
               
         	   



            



?>